<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'basic';
$return=array();
/*******basic*******/
if($_RQ['op']=='basic'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		if($postdata['takeover']){
			$da=array('backtype'=>8,'key'=>'jy_chatgpt1','status'=>1,'takeover'=>1,'title'=>'接管chatgpt聊天','event'=>'create','keyword'=>trim($postdata['takeover']));
			$postdata['takeoverid']=cfc('core')->save_back($da,'jy_chatgpt');
		}elseif($postdata['takeoverid']){
			cfc('core')->del_back($postdata['takeoverid']);
			$postdata['takeoverid']=0;
		}
		if($postdata['outover']){
			$da=array('backtype'=>8,'key'=>'jy_chatgpt2','status'=>1,'outover'=>1,'title'=>'退出chatgpt聊天','event'=>'create','keyword'=>trim($postdata['outover']));
			$postdata['outoverid']=cfc('core')->save_back($da,'jy_chatgpt');
		}elseif($postdata['outoverid']){
			cfc('core')->del_back($postdata['outoverid']);
			$postdata['outoverid']=0;
		}
		$this->plugin_setting('basic',$postdata);
		exi('设置成功');
	}
	$footernav =array(
		array('title'=>'首页','icon'=>'icon-shouye','action'=>'jy_chatgpt/index/'),
		array('title'=>'我的对话','icon'=>'icon-viewlist','action'=>'jy_chatgpt/mychat/'),
		array('title'=>'个人中心','icon'=>'icon-wo1','action'=>'jy_chatgpt/home/'),
	);
	//$yufee=$this->model('model')->yufee($content);
	$return['item']['yufee']=$yufee;
	$return['item']=$this->plugin_setting('basic');
	$tip='文心一言内嵌版：无需注册账户，无需购买接口次数；直接内嵌页面，方便某些特殊场景使用！';
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基本信息',
				'list'=>array(
					array('type'=>'tip','title'=>$tip),
					array('type'=>'string','title'=>'文心一言地址','name'=>'apiurl','help'=>'默认：https://chat.baidu.com'),
					array('type'=>'string','title'=>'平台标题','name'=>'title','help'=>''),
					array('type'=>'string','title'=>'分享标题','name'=>'share_title'),
					array('type'=>'string','title'=>'分享描述','name'=>'share_desc'),
					array('type'=>'image','title'=>'分享图片','name'=>'share_image','help'=>'建议尺寸：高320px*宽640px'),
				),
			),
			array(
				'title'=>'金币机制',
				'list'=>array(
					array('type'=>'tip','title'=>'务必先设置-我的站点--支付参数--虚拟币--金币--支持显示;
					</br>优先启用VIP机制；已购买VIP的不消耗金币！
					'),
					array('type'=>'unitstring','unit'=>'个/人','title'=>'按人分享赚N金币','name'=>'bi_sale'),
					array('type'=>'unitstring','unit'=>'个/次','title'=>'按次分享赚N金币','name'=>'bi_sale2'),
					array('type'=>'unitstring','unit'=>'个','title'=>'按次分享赚每日上限','name'=>'bi_sale2max'),
				)
			)
		)
	);
	$return['apis']=$this->apis;
	$return['htmls']=$htmls;
	exi($return);
}
/*******basic*******/
/*******op*******/
